*for REStat paper "Breastfeeding and Children's Early Cognitive Outcomes."
libname dd 'X:\Donnanew';

data a;
set dd.pindpcg;

proc sort;  by intnum83; run;

data b;
  set dd.pfam08;
  keep intnum83 regne83 regnc83 regs83 regw83 black83 hisp83;
  proc sort;  by intnum83;  run;

data c;
merge a b;  by intnum83; 

if pcg97id ne .;

proc sort;  by intnum84;  run;

data d;
set dd.pfam08;
keep intnum84 regne84 regnc84 regs84 regw84 black84 hisp84;

proc sort;  by intnum84;  run;

data e;
merge c d;  by intnum84;

if pcg97id ne .;

proc sort;  by intnum85;  run;

data f;
set dd.pfam08;
keep intnum85 regne85 regnc85 regs85 regw85 hblack85 hhisp85 wblack85 whisp85 ;

proc sort;  by intnum85;  run;

data g;
merge e f;  by intnum85;

if pcg97id ne .;

proc sort;  by intnum86;  run;

data h;
set dd.pfam08;
keep intnum86 regne86 regnc86 regs86 regw86 hblack86 hhisp86 wblack86 whisp86;

proc sort;  by intnum86;  run;

data i;
merge g h;  by intnum86;

if pcg97id ne .;

proc sort;  by intnum87;  run;

data j;
set dd.pfam08;
keep intnum87 regne87 regnc87 regs87 regw87 hblack87 hhisp87 wblack87 whisp87 ;

proc sort;  by intnum87;  run;

data k;
merge i j;  by intnum87;  

if pcg97id ne .;

proc sort;  by intnum88;  run;

data l;
set dd.pfam08;
keep intnum88 regne88 regnc88 regs88 regw88 hblack88 hhisp88 wblack88 whisp88 ;

proc sort;  by intnum88;  run;

data m;
merge k l;  by intnum88;  

if pcg97id ne .;

proc sort;  by intnum89;  run;

data n;
set dd.pfam08;
keep intnum89 regne89 regnc89 regs89 regw89 hblack89 hhisp89 wblack89 whisp89 ;

proc sort;  by intnum89;  run;

data o;
merge m n;  by intnum89;  

if pcg97id ne .;

proc sort;  by intnum90;  run;

data p;
set dd.pfam08;
keep intnum90 regne90 regnc90 regs90 regw90 hblack90 hhisp90 wblack90 whisp90 ;

proc sort;  by intnum90;  run;

data q;
merge o p;  by intnum90;  

if pcg97id ne .;

proc sort;  by intnum91;  run;

data r;
set dd.pfam08;
keep intnum91 regne91 regnc91 regs91 regw91 hblack91 hhisp91 wblack91 whisp91 ;

proc sort;  by intnum91;  run;

data s;
merge q r;  by intnum91;  

if pcg97id ne .;

proc sort;  by intnum92;  run;

data t;
set dd.pfam08;
keep intnum92 regne92 regnc92 regs92 regw92 hblack92 hhisp92 wblack92 whisp92 ;

proc sort;  by intnum92;  run;

data u;
merge s t;  by intnum92;  

if pcg97id ne .;

proc sort;  by intnum93;  run;

data v;
set dd.pfam08;
keep intnum93 regne93 regnc93 regs93 regw93 hblack93 hhisp93 wblack93 whisp93 ;

proc sort;  by intnum93;  run;

data w;
merge u v;  by intnum93;  

if pcg97id ne .;

proc sort;  by intnum94;  run;

data x;
set dd.pfam08;
keep intnum94 regne94 regnc94 regs94 regw94 hblack94 hhisp94 wblack94 whisp94 ;

proc sort;  by intnum94;  run;

data y;
merge w x;  by intnum94;  

if pcg97id ne .;

proc sort;  by intnum95;  run;

data z;
set dd.pfam08;
keep intnum95 regne95 regnc95 regs95 regw95 hblack95 hhisp95 wblack95 whisp95 ;

proc sort;  by intnum95;  run;

data za;
merge y z;  by intnum95;  

if pcg97id ne .;

proc sort;  by intnum96;  run;

data zb;
set dd.pfam08;
keep intnum96 regne96 regnc96 regs96 regw96 hblack96 hhisp96 wblack96 whisp96 ;

proc sort;  by intnum96;  run;

data zc;
merge za zb;  by intnum96;  

if pcg97id ne .;

proc sort;  by intnum97;  run;

data zd;
set dd.pfam08;
keep intnum97 regne97 regnc97 regs97 regw97 faminc97 ;

proc sort;  by intnum97;  run;

data dd.pfam082;
merge zc zd;  by intnum97;  

if pcg97id ne .;



proc means;
run;
